package cn.bird.storm.validated.paramcheck.model.stringscope;

import cn.bird.storm.validated.paramcheck.inter.ICheckBean;
import cn.hutool.core.collection.CollUtil;
import lombok.Builder;
import lombok.Getter;

import java.util.List;
import java.util.function.Predicate;

@Getter
@Builder
public class StringScopeCheckBean implements ICheckBean<String> {
    /**
     * 提示语
     */
    private String msg;

    private String value;
    /**
     * 取值范围
     */
    private List<String> scope;

    @Override
    public Predicate<String> getPassTest() {
        if (CollUtil.isEmpty(scope)) {
            return s -> false;
        }
        return scope::contains;
    }

}
